<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Transformer核心知识卡片</title>
    <script src="../../assets/js/tailwindcss.js"></script>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&family=Noto+Serif+SC:wght@400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', sans-serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
        }
        .highlight-blue {
            color: #2563eb;
            font-weight: 600;
        }
        .highlight-purple {
            color: #7c3aed;
            font-weight: 600;
        }
        .grid-card-item {
            transition: all 0.3s ease;
        }
        .grid-card-item:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
        .attention-flow {
            position: relative;
        }
        .attention-flow::after {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(90deg, rgba(121, 40, 202, 0.1) 0%, rgba(121, 40, 202, 0) 100%);
            border-radius: 0.5rem;
            pointer-events: none;
        }
    </style>
</head>
<body class="bg-gray-50">
    <div class="max-w-4xl mx-auto my-8 px-6">
        <!-- 主卡片容器 -->
        <article class="bg-white rounded-xl shadow-xl overflow-hidden">
            <!-- 头部 - Hero部分 -->
            <header class="hero-gradient text-white p-8">
                <div class="flex items-center mb-4">
                    <i class="fas fa-brain text-3xl mr-3"></i>
                    <h1 class="text-3xl md:text-4xl font-bold">Transformer架构核心解析</h1>
                </div>
                <p class="text-xl opacity-90">革命性神经网络架构如何重塑自然语言处理</p>
            </header>

            <!-- 核心内容区 -->
            <section class="p-8">
                <!-- 第一部分：Transformer概述 -->
                <div class="mb-10">
                    <h2 class="text-2xl font-bold mb-4 flex items-center text-gray-800">
                        <i class="fas fa-star text-yellow-500 mr-2"></i>
                        <span class="highlight-purple">✨ Transformer是什么？为何重要？</span>
                    </h2>
                    <p class="text-lg leading-relaxed mb-6 text-gray-700">
                        Transformer是一种<span class="highlight-blue">革命性神经网络架构</span>（2017年由谷歌提出），彻底改变了自然语言处理领域。其核心突破在于：
                    </p>
                    
                    <!-- 关键特性网格 -->
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
                        <div class="grid-card-item bg-gray-50 p-5 rounded-lg border border-gray-200">
                            <div class="flex items-start mb-2">
                                <i class="fas fa-exchange-alt text-blue-500 mt-1 mr-3"></i>
                                <h3 class="font-semibold text-gray-800">替代传统模型</h3>
                            </div>
                            <p class="text-gray-600">取代了RNN（循环神经网络）和LSTM（长短期记忆网络）等序列处理模型</p>
                        </div>
                        <div class="grid-card-item bg-gray-50 p-5 rounded-lg border border-gray-200">
                            <div class="flex items-start mb-2">
                                <i class="fas fa-bolt text-purple-500 mt-1 mr-3"></i>
                                <h3 class="font-semibold text-gray-800">核心能力</h3>
                            </div>
                            <p class="text-gray-600">能同时分析句子中所有词语的关系，而非逐字处理</p>
                        </div>
                        <div class="grid-card-item bg-gray-50 p-5 rounded-lg border border-gray-200">
                            <div class="flex items-start mb-2">
                                <i class="fas fa-robot text-indigo-500 mt-1 mr-3"></i>
                                <h3 class="font-semibold text-gray-800">应用场景</h3>
                            </div>
                            <p class="text-gray-600">ChatGPT的底层技术、机器翻译、文本生成等AI系统的核心引擎</p>
                        </div>
                    </div>
                    
                    <!-- 类比说明 -->
                    <div class="bg-blue-50 p-5 rounded-lg border-l-4 border-blue-500 mb-6">
                        <div class="flex">
                            <i class="fas fa-lightbulb text-blue-500 text-2xl mr-3 mt-1"></i>
                            <div>
                                <h3 class="font-bold text-blue-800 mb-2">🔍 类比理解</h3>
                                <p class="text-gray-700">
                                    <span class="font-semibold">传统模型</span>像一组<span class="highlight-blue">隔离小房间的译者</span>（RNN/LSTM），每人只能看到前一位的笔记；
                                    <span class="font-semibold">Transformer</span>则是<span class="highlight-purple">开放式协作空间</span>，每位译者瞬间看到全书内容，并互相讨论关键关联词。
                                </p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 第二部分：自注意力机制 -->
                <div>
                    <h2 class="text-2xl font-bold mb-4 flex items-center text-gray-800">
                        <i class="fas fa-cogs text-indigo-500 mr-2"></i>
                        <span class="highlight-purple">✨ 核心机制：自注意力（Self-Attention）</span>
                    </h2>
                    
                    <!-- 工作原理 -->
                    <div class="mb-8">
                        <h3 class="text-xl font-semibold mb-3 text-gray-700 flex items-center">
                            <span class="w-6 h-6 bg-indigo-500 rounded-full flex items-center justify-center text-white mr-2 text-sm">1</span>
                            📌 工作原理
                        </h3>
                        
                        <!-- 三步曲流程 -->
                        <div class="attention-flow bg-white p-5 rounded-lg border border-gray-200 mb-4">
                            <h4 class="font-bold text-gray-700 mb-3">核心三步曲：</h4>
                            <ul class="space-y-3">
                                <li class="flex items-start">
                                    <span class="bg-blue-100 text-blue-800 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">→</span>
                                    <div>
                                        <span class="font-semibold highlight-blue">提问（Query）</span>：当前处理的词（如"苹果"）提出需求
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <span class="bg-purple-100 text-purple-800 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">→</span>
                                    <div>
                                        <span class="font-semibold highlight-purple">匹配关联（Key-Value）</span>：扫描句中所有词，找出相关词（如"红色"对应颜色，"吃"对应动作）
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <span class="bg-indigo-100 text-indigo-800 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">→</span>
                                    <div>
                                        <span class="font-semibold text-indigo-600">信息整合</span>：将相关词的语义加权融合到"苹果"的理解中
                                    </div>
                                </li>
                            </ul>
                        </div>
                        
                        <!-- 生活案例 -->
                        <div class="bg-purple-50 p-5 rounded-lg border-l-4 border-purple-500">
                            <div class="flex">
                                <i class="fas fa-comments text-purple-500 text-2xl mr-3 mt-1"></i>
                                <div>
                                    <h4 class="font-bold text-purple-800 mb-2">🌟 生活案例</h4>
                                    <p class="text-gray-700">
                                        如同会议发言人：当你说"项目截止时间"，与会者自动关联"日历""加班""优先级"等词，而非无关词汇。
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 多头注意力 -->
                    <div>
                        <h3 class="text-xl font-semibold mb-3 text-gray-700 flex items-center">
                            <span class="w-6 h-6 bg-indigo-500 rounded-full flex items-center justify-center text-white mr-2 text-sm">2</span>
                            📌 多头注意力（Multi-Head）
                        </h3>
                        
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                            <div class="bg-indigo-50 p-5 rounded-lg">
                                <h4 class="font-bold text-indigo-800 mb-2">作用</h4>
                                <p class="text-gray-700">扩展模型的"观察视角"</p>
                            </div>
                            <div class="bg-gradient-to-r from-indigo-50 to-purple-50 p-5 rounded-lg">
                                <h4 class="font-bold text-gray-800 mb-2">类比</h4>
                                <ul class="space-y-2">
                                    <li class="flex items-start">
                                        <span class="bg-gray-200 text-gray-800 rounded-full w-5 h-5 flex items-center justify-center mr-2 mt-0.5 flex-shrink-0 text-xs">→</span>
                                        <span>单头注意力 = 1位专家从单一角度分析句子</span>
                                    </li>
                                    <li class="flex items-start">
                                        <span class="bg-indigo-100 text-indigo-800 rounded-full w-5 h-5 flex items-center justify-center mr-2 mt-0.5 flex-shrink-0 text-xs">→</span>
                                        <span class="font-semibold highlight-purple">多头（如8组） = 专家组会议</span>，分别从情感/语法/逻辑等维度交叉验证
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </section>

            <!-- 页脚 -->
            <footer class="bg-gray-50 p-6 border-t border-gray-200">
                <div class="flex justify-between items-center text-sm text-gray-500">
                    <div>
                        <i class="far fa-lightbulb mr-1"></i> AI知识卡片
                    </div>
                    <div>
                        <i class="fas fa-code-branch mr-1"></i> 神经网络架构系列
                    </div>
                </div>
            </footer>
        </article>
    </div>
</body>
</html>